PHP Arrays by Steve Prettyman

PHP Arrays by Steve Prettyman

Author:Steve Prettyman
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA


Example 4-9.update_associative2.php

If we do name the rows, then, except for the array itself, only one slight change is needed. The data type for the subscript either needs to be changed to string or to be removed altogether. Also, the subscript passed into the function needs to give the name of the array to be replaced.

Both of these examples would replace the array containing Pete with the array containing Peter. Actually it will also insert the array if the position does not currently exist in the array.

Let’s take a look at replacing one value.

declare(strict_types=1);

function update_array_value(int $first_subscript, string $second_subscript, $value)

{

$customer_record = array (

array( 'first_name' =>'Pete' ,'last_name' =>'Smith' ,

'address' =>'123 Main Street' ,'city' => 'Atlanta',

'state' =>'GA', 'zip_code' =>30001

),

array( 'first_name' =>'Sally' ,'last_name' =>'Parisi' ,



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.